<template>
  <button
    :class="[
      'my-button',
      type,
      size,

      { buttonDisable: disabled },
      { buttonRound: round },
    ]"
    :disabled="disabled"
    :style="{
      width: width + 'px',
      height: height + 'px',
      'font-size': font + 'px',
      color: fontColor,
    }"
  >
    <span class="u-text">
      <slot>{{ name }} </slot>
    </span>
  </button>
</template>

<script lang="ts">
export default {
  //组件名称
  name: "ls-button",
};
</script>
<script lang="ts" setup>
import { withDefaults } from "vue";
interface Props {
  name?: string; // 按钮文本 string | slot
  type?: "default" | "primary" | "danger" | "dashed" | "text" | "link" | "warn"; // 按钮类型
  size?: "small" | "middle" | "large";
  disabled?: boolean /* 是否禁用 */;
  round?: boolean /* 是否圆角 */;
  width?: string /* 按钮宽度 */;
  height?: string /* 按钮高度 */;
  font?: string /* 按钮字体 */;
  fontColor?: string /* 字体颜色 */;
}
/* 设置默认值 */
const props = withDefaults(defineProps<Props>(), {
  name: "按钮",
  type: "default",
  size: "middle",
  disabled: false,
  round: false,
});
</script>

<style lang="scss" scoped>
$fade-primary-bg-color: rgba(56, 117, 246, 0.8);
$fade-default-bg-color: rgba(162, 218, 255, 0.8);
$fade-success-bg-color: rgba(103, 194, 58, 0.8);
$fade-warn-bg-color: rgba(230, 162, 60, 0.8);
$fade-danger-bg-color: rgba(245, 108, 108, 0.8);
.my-button {
  color: black;
  border: none;
  outline: none;
  font-weight: 500;
  letter-spacing: 2px;
  line-height: 1.5714285714285714;
  color: rgba(0, 0, 0, 0.88);
  white-space: nowrap;
  width: 100px;
  height: 60px;

  .u-text {
    display: inline-flex;
    align-items: center;
    height: 100%;
  }

  &.primary {
    background-color: rgb(56, 117, 246);
    color: #fff;

    transition: background-color 0.3s ease;
    outline: none;
    &:hover {
      background-color: $fade-primary-bg-color; /* 将背景颜色淡化到 80% */
    }
  }
  &.success {
    background-color: rgb(103, 194, 58);
    color: #fff;
    outline: none;
    &:hover {
      background-color: $fade-success-bg-color; /* 将背景颜色淡化到 80% */
    }
  }
  &.warn {
    background-color: rgb(230, 162, 60);
    color: #fff;
    outline: none;
    &:hover {
      background-color: $fade-warn-bg-color; /* 将背景颜色淡化到 80% */
    }
  }
  &.danger {
    background-color: rgb(245, 108, 108);
    color: #fff;
    outline: none;
    &:hover {
      background-color: $fade-danger-bg-color; /* 将背景颜色淡化到 80% */
    }
  }
  &.default {
    background-color: rgb(255, 255, 255);
    border: 1px rgb(214, 213, 213) solid;
    color: black;
    outline: none;
    &:hover {
      background-color: $fade-default-bg-color; /* 将背景颜色淡化到 80% */
      border: none;
    }
  }
  &.small {
    width: 80px;
    height: 30px;
    font-size: 11px;
    height: 24px;
    padding: 0px 7px;
    outline: none;
  }
  &.middle {
    font-size: 14px;
    height: 32px;
    padding: 4px 15px;

    outline: none;
  }
  &.large {
    width: 120px;
    height: 60px;
    font-size: 17px;

    padding: 6.428571428571429px 15px;

    outline: none;
  }
  &.buttonDisable {
    opacity: 0.6;
    cursor: not-allowed;
  }
  &.buttonRound {
    border-radius: 15px;
  }
}
.spin-content {
  display: inline-block;
  border: 1px solid #91d5ff;
  background-color: #e6f7ff;
  padding: 30px;
}
.u-spin {
  display: inline-block;
  width: 100px;
  height: 100px;
}
</style>
